<?php

namespace Drupal\wx_transfers\ViewsController;

use Drupal\wx_transfers\ViewsController\handler\field\WxTransfersAmountViewsField;
use Drupal\wx_transfers\ViewsController\handler\field\WxTransfersCheckNameViewsField;
use Drupal\wx_transfers\ViewsController\handler\field\WxTransfersEditLinkViewsField;
use Drupal\wx_transfers\ViewsController\handler\field\WxTransfersStatusViewsField;
use Drupal\wx_transfers\ViewsController\handler\filter\WxTransfersCheckNameViewsFilter;
use Drupal\wx_transfers\ViewsController\handler\filter\WxTransfersStatusViewsFilter;
use EntityDefaultViewsController;


class WxTransfersViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => WxTransfersEditLinkViewsField::class,
        ],
      ];
      $info[$table]['check_name'] = [
        'title' => '0 NO_CHECK不校验真实姓名 1 FORCE_CHECK强校验真实姓名',
        'help' => '0 NO_CHECK不校验真实姓名 1 FORCE_CHECK强校验真实姓名',
        'real field' => 'check_name',
        'field' => [
          'handler' => WxTransfersCheckNameViewsField::class,
        ],
        'filter' => [
          'handler' => WxTransfersCheckNameViewsFilter::class,
        ],
      ];
      $info[$table]['amount'] = [
        'title' => '企业付款金额，单位为分',
        'help' => '企业付款金额，单位为分',
        'real field' => 'amount',
        'field' => [
          'handler' => WxTransfersAmountViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 处理中 1 失败(可以重试) 2 失败(不可重试) 3 成功',
        'help' => '状态 0 处理中 1 失败(可以重试) 2 失败(不可重试) 3 成功',
        'real field' => 'status',
        'field' => [
          'handler' => WxTransfersStatusViewsField::class,
        ],
        'filter' => [
          'handler' => WxTransfersStatusViewsFilter::class,
        ],
      ];
      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
